package com.examples.ry.layouts;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class GridDataExcessSpace {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		GridLayout layout = new GridLayout();
		layout.numColumns = 3;
		shell.setLayout(layout);
		for (int i = 0; i < 3; i++) {
			Button button = new Button(shell, SWT.PUSH);
			button.setText("Button" + i);
			GridData data = new GridData();
			data.horizontalAlignment = SWT.FILL;
			data.verticalAlignment = SWT.FILL;
			
			/*
			 * Cntrols will resize as u resize the Shell
			 */
			//if (i == 1) {
				data.grabExcessHorizontalSpace = true;
				data.grabExcessVerticalSpace = true;
			//}
			button.setLayoutData(data);
		}
		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

}
